package cn.wuxing.mediation.web.controller.contradiction;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import cn.wuxing.mediation.common.core.page.PageDomain;
import cn.wuxing.mediation.common.core.page.TableSupport;
import cn.wuxing.mediation.system.domain.StgDscHuzBiz018VisitPetitionDfWxq;
import cn.wuxing.mediation.system.domain.vo.PetitionVo;
import cn.wuxing.mediation.system.service.IPetitionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.wuxing.mediation.common.annotation.Log;
import cn.wuxing.mediation.common.core.controller.BaseController;
import cn.wuxing.mediation.common.core.domain.AjaxResult;
import cn.wuxing.mediation.common.enums.BusinessType;
import cn.wuxing.mediation.system.domain.CmProvincialRecordInformation;
import cn.wuxing.mediation.system.service.ICmProvincialRecordInformationService;
import cn.wuxing.mediation.common.utils.poi.ExcelUtil;
import cn.wuxing.mediation.common.core.page.TableDataInfo;

/**
 * 省市回流_信访件_信访事项办理记录信息Controller
 *
 * @author mediation
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/cm/information")
public class CmProvincialRecordInformationController extends BaseController
{
    @Resource
    private IPetitionService petitionService;

    /**
     * 查询省市回流_信访件_信访事项办理记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('cm:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetitionVo petitionVo)
    {
        startPage();
        List<PetitionVo> list = petitionService.selectAll(petitionVo);
        return getDataTable(list);
    }

    /**
     * 导出省市回流_信访件_信访事项办理记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('cm:information:export')")
    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetitionVo petitionVo)
    {
        if(petitionVo.getIds()==null||petitionVo.getIds().size()==0){//如果没勾选,就导出当前分页
            PageDomain pageDomain = TableSupport.buildPageRequest();
            Integer pageNum = pageDomain.getPageNum();
            Integer pageSize = pageDomain.getPageSize();
            petitionVo.setCurrentPage((pageNum-1)*pageSize);
            petitionVo.setCurrentPageSize(pageSize);
        }
        List<PetitionVo> list = petitionService.selectAllExport(petitionVo);
        ExcelUtil<PetitionVo> util = new ExcelUtil<PetitionVo>(PetitionVo.class);
//        util.exportExcel(response, list, "省市回流_信访件_信访事项办理记录信息数据");
        util.exportExcel(response, list, "阳光信访热件信息数据");
    }

    /**
     * 获取信访事项信息
     */
    @PreAuthorize("@ss.hasPermi('cm:information:query')")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(@RequestParam("id") String id,
                              @RequestParam("sourceType")String sourceType)
    {
        if(sourceType!=null){
            if(("5").equals(sourceType)){//信访信息
                return success(petitionService.selectStgDscHuzBiz018VisitPetitionDfWxq(id));
            }
            if("6".equals(sourceType)){//市阳光信访
                return success(petitionService.selectStgSxfjYgrxXfsjDfWxq(id));
            }
            if("7".equals(sourceType)){//省阳光信访
                return success(petitionService.selectStgSdsjjDscDa018Tab1010201ValidOldHuzDfWxq(id));
            }
            if("8".equals(sourceType)){//人社
                return success(petitionService.qrlsbjStgDscHuzBiz029SjztjDfWxq(id));
            }
            return error("传参有误！");
        }
        return error("传参有误！");
    }

    /**
     * 新增省市回流_信访件_信访事项办理记录信息
     */
//    @PreAuthorize("@ss.hasPermi('cm:information:add')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        return toAjax(cmProvincialRecordInformationService.insertCmProvincialRecordInformation(cmProvincialRecordInformation));
//    }

    /**
     * 修改省市回流_信访件_信访事项办理记录信息
     */
//    @PreAuthorize("@ss.hasPermi('cm:information:edit')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        return toAjax(cmProvincialRecordInformationService.updateCmProvincialRecordInformation(cmProvincialRecordInformation));
//    }

    /**
     * 删除省市回流_信访件_信访事项办理记录信息
     */
//    @PreAuthorize("@ss.hasPermi('cm:information:remove')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{xfjbhs}")
//    public AjaxResult remove(@PathVariable String[] xfjbhs)
//    {
//        return toAjax(cmProvincialRecordInformationService.deleteCmProvincialRecordInformationByXfjbhs(xfjbhs));
//    }

    //    @Autowired
//    private ICmProvincialRecordInformationService cmProvincialRecordInformationService;
//
//    /**
//     * 查询省市回流_信访件_信访事项办理记录信息列表
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        startPage();
//        List<CmProvincialRecordInformation> list = cmProvincialRecordInformationService.selectCmProvincialRecordInformationList(cmProvincialRecordInformation);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出省市回流_信访件_信访事项办理记录信息列表
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:export')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        List<CmProvincialRecordInformation> list = cmProvincialRecordInformationService.selectCmProvincialRecordInformationList(cmProvincialRecordInformation);
//        ExcelUtil<CmProvincialRecordInformation> util = new ExcelUtil<CmProvincialRecordInformation>(CmProvincialRecordInformation.class);
//        util.exportExcel(response, list, "省市回流_信访件_信访事项办理记录信息数据");
//    }
//
//    /**
//     * 获取省市回流_信访件_信访事项办理记录信息详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:query')")
//    @GetMapping(value = "/{xfjbh}")
//    public AjaxResult getInfo(@PathVariable("xfjbh") String xfjbh)
//    {
//        return success(cmProvincialRecordInformationService.selectCmProvincialRecordInformationByXfjbh(xfjbh));
//    }
//
//    /**
//     * 新增省市回流_信访件_信访事项办理记录信息
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:add')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        return toAjax(cmProvincialRecordInformationService.insertCmProvincialRecordInformation(cmProvincialRecordInformation));
//    }
//
//    /**
//     * 修改省市回流_信访件_信访事项办理记录信息
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:edit')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody CmProvincialRecordInformation cmProvincialRecordInformation)
//    {
//        return toAjax(cmProvincialRecordInformationService.updateCmProvincialRecordInformation(cmProvincialRecordInformation));
//    }
//
//    /**
//     * 删除省市回流_信访件_信访事项办理记录信息
//     */
//    @PreAuthorize("@ss.hasPermi('cm:information:remove')")
//    @Log(title = "省市回流_信访件_信访事项办理记录信息", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{xfjbhs}")
//    public AjaxResult remove(@PathVariable String[] xfjbhs)
//    {
//        return toAjax(cmProvincialRecordInformationService.deleteCmProvincialRecordInformationByXfjbhs(xfjbhs));
//    }
}
